#include "BaseGame.h"
#include "Timer.h"

extern HINSTANCE g_hInstance;
//---------------------------------------------------------------------------------------------//
bool BaseGame::Start()
{
	if(!wndw.Create())
		return false;
	graphics.Init(wndw.GetHwnd());
	Timer::Start();
	return OnStart(graphics);
}
//---------------------------------------------------------------------------------------------//
void BaseGame::Loop()
{
	MSG msg;
	ZeroMemory(&msg, sizeof(MSG));

	while (msg.message != WM_QUIT && OnUpdate())
	{
		if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		graphics.Clear();
		
		graphics.BeginScene();
		
		OnDraw(graphics);
		
		graphics.EndScene();
		
		graphics.Present(wndw.GetHwnd());

		Timer::Measure();
	}
}
//---------------------------------------------------------------------------------------------//
void BaseGame::ShutDown()
{
	graphics.DeInit();
	OnShutDown();
}